<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全部商品管理</title>
    <link rel="stylesheet" href="/static/lib/layui-v2.5.6/layui-v2.5.6/layui/css/layui.css">
    <style>
        .layui-table-cell{
            height:38px;
            line-height: 38px;
        }
        .layui-col-xs1{
            height: 66px;
            line-height: 66px;
            margin: 5px 5px 0 0;
            text-align: center;
            font-size: 20px;
            cursor: pointer;
        }
        .info{
            font-size: 14px;
            color: rgb(110, 108, 108);
            line-height: 36px;
        }
        .layui-icon-search{
            font-size: 30px;
            color: #009688;
            cursor: pointer;
            margin-left: 40px;
        }


        .btn-box {
            position: relative;
        }

        .file-ipt {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0; 
        }

        .btn {
            width: 100px;
            height: 30px;
            background-color: white;
            color: #009688;
            margin-right: 80px;
            border: none;
            border-radius: 10px;
        }
        input[type="checkbox"]{width:20px;height:20px;display: inline-block;text-align: center;vertical-align: middle; line-height: 18px;position: relative;}
        input[type="checkbox"]::before{content: "";position: absolute;top: 0;left: 0;background: #fff;width: 100%;height: 100%;border: 1px solid #d9d9d9}
        input[type="checkbox"]:checked::before{content: "\2713";background-color: #fff;position: absolute;top: 0;left: 0;width:100%;border: 1px solid #e50232;color:#e50232;font-size: 20px;font-weight: bold;}    
    </style>
</head>
<body>
    <table id="demo" lay-filter="test"></table>


<!-- 订单详细页面 -->
  <div id="goodslistDetails" style="display: none;">
      <h3 class="goodsname_info1" style="text-align: center;margin-bottom: 20px;"></h3>
      <div class="layui-form-item">
        <label class="layui-form-label">商品名称</label>
        <div class="layui-input-block goodsname_info1 info"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品分类</label>
        <div class="layui-input-block goodscategory_info1 info"></div>
    </div>
    <button type="button" class="layui-btn layui-btn-xs layui-btn-radius goodslistDetails_modbtn">信息修改</button>
    <hr/>
    <div class="layui-form-item">
        <div class="layui-row layui-col-space4 pic_info1">
            <div class="layui-col-xs4">
            
            </div>
        </div>
    </div>
    <form class="layui-form">
        <div class="layui-form-item btn-box" style="margin: 30px 0 0 30px;">
            <button class="btn">点击上传图片</button>
            <input type="file" id="imgPath" class="file-ipt">
        </div>
    </form>
    <button type="button" class="layui-btn layui-btn-xs layui-btn-radius pic_updbtn">上传图片</button>
    <button type="button" class="layui-btn layui-btn-xs layui-btn-radius pic_delbtn">删除图片</button>
    <hr>
    <table class="layui-table">
        <colgroup>
          <col width="150">
          <col width="200">
          <col>
        </colgroup>
        <thead>
          <tr>
            <th>id</th>
            <th>价格</th>
            <th>商品规格</th>
            <th>操作</th>
          </tr> 
        </thead>
        <tbody class="specifications_info1">
          <tr>
            <td>贤心</td>
            <td>2016-11-29</td>
            <td>人生就像是一场修行</td>
          </tr>
        </tbody>
    </table>
    <button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_add">增加规格</button>
    
  </div> 

<!-- //商品增加和修改 -->
<div id="goodsUpdate" style="display: none;margin-top: 30px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-inline">
                <select name="goodsCategory_2" lay-verify="" id="goodsCategory" class="goodsCategory">
                    <option value="">商品分类</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-inline">
                <input id="goodsName" type="text" name="goodsName" required lay-verify="required" placeholder="请输入商品名称" class="layui-input">
            </div>
        </div>
        
    </form>
</div>


<!-- 商品规格的增加和修改 -->
<div id="specificationUpdate" style="display: none;margin-top: 30px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">商品价格</label>
            <div class="layui-input-inline">
                <input id="specificationPrice_2" type="text" name="specificationPrice_2" required lay-verify="required" placeholder="4.45" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品规格</label>
            <div class="layui-input-inline">
                <input id="specification_2" type="text" name="specification_2" required lay-verify="required" placeholder="1.25斤/箱" class="layui-input">
            </div>
        </div>
        
    </form>
</div>








    <script type="text/html" id="barDemo">
        <i class="layui-icon layui-icon-list" lay-event="goodsUpdate_1" title="商品详细"></i>
        <i class="layui-icon layui-icon-delete" lay-event="goodsDel_1" title="商品删除"></i>
        <i class="layui-icon layui-icon-upload-circle" lay-event="goodsStatus_1" title="商品状态改变"></i>
    </script>

    <script type="text/html" id="toolbarDemo">
        <div class="layui-inline" style="width: 150px;">
            <select name="goodsCategory_2" lay-verify="" id="goodsCategory_2" class="goodsCategory">
                <option value="">商品分类</option>
            </select>
        </div>
        <div class="layui-inline" style="width: 150px;">
            <select name="goodsStatus_2" lay-verify="" id="goodsStatus_2">
                <option value="">商品状态</option>
                <option value="0">未上架</option>
                <option value="1">正常</option>
            </select>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 150px;">
              <input type="text" name="goodsName_2" id="goodsName_2" placeholder="输入商品名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <i class="layui-icon layui-icon-search" lay-event="goodslistSearch_2" title="搜索刷新"></i>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-sm layui-btn-radius" lay-event="goodsAdd" style="margin-top:8px">添加商品</button>
        </div>
    </script>


    
    <script src="../lib/layui-v2.5.6/layui-v2.5.6/layui/layui.js"></script>
    <script>
        
        
        
        

        layui.use(['table','laydate','form','util','form'], function(){
            var $ = layui.jquery;
            var table = layui.table;
            var laydate =layui.laydate;
            var form = layui.form;
            var util = layui.util;
            var form = layui.form;

            getCategory()
            table.render({
                elem: '#demo',
                height: 'full-60',
                url: '/admin/commodity/queryCommodity', //数据接口
                page: true, //开启分页
                toolbar: '#toolbarDemo',
                defaultToolbar: [],
                id: 'adTest',
                cols: [[ //表头
                {field: 'id', title: '商品ID', width:'10%', sort: true, fixed: 'left'},
                {field: 'commodityName', title: '商品名称', width:'30%',},
                {field: 'category', title: '商品类别', templet:"<div>{{ d.category.categoryName }}</div>", width:'15%', sort: true},
                {field: 'picture', title: '图片数量', templet:'<div>{{d.picture.length}}</div>', width:'10%'} ,
                {field: 'specifications', title: '规格数量', templet:'<div>{{d.specifications.length}}</div>', width: '10%'},
                {field: 'commodityStatus', title: '商品状态', width: '10%', templet:'<div>{{goodsStatus(d.commodityStatus)}}</div>', sort: true},
                {fixed: 'right', width:'10%', align:'center', toolbar: '#barDemo'}
                ]],


                parseData: function(res){ //res 即为原始返回的数据
                    return {
                    "code": res.success, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                    };
                },
                request: {
                    pageName: 'pageNum', //页码的参数名称，默认：page
                    limitName: 'pageSize' //每页数据量的参数名，默认：limit
                },
                response: {
                    // statusName: 'success', //规定数据状态的字段名称，默认：code
                    statusCode: true //规定成功的状态码，默认：0
                }
            });
        
            table.on('toolbar(test)', function(obj){
                sessionStorage.setItem("goodsCategory_2_1", $("#goodsCategory_2").val());
                sessionStorage.setItem("goodsStatus_2_1", $("#goodsStatus_2").val());
                sessionStorage.setItem("goodsName_2_1", $("#goodsName_2").val());
                switch(obj.event){
                    case 'goodslistSearch_2':
                    var category = $("#goodsCategory_2").val()
                    var commodity_status = $("#goodsStatus_2").val()
                    var commodity_name = $("#goodsName_2").val()
                    
                    table.reload('adTest', {
                        where: { //设定异步数据接口的额外参数，任意设
                            category: $("#goodsCategory_2").val(),
                            commodity_status: $("#goodsStatus_2").val(),
                            commodity_name: $("#goodsName_2").val()
                        },
                        page: {
                            curr: 1 //重新从第 1 页开始
                        },
                    });
                    getCategory(category)

                    if (sessionStorage.getItem("goodsStatus_2_1") == '') {
                        $("#goodsStatus_2").attr('text','商品状态')
                    }else if(sessionStorage.getItem("goodsStatus_2_1") == '0'){
                        $("#goodsStatus_2 option[value= '0']").attr("selected", true);
                    }else if (sessionStorage.getItem("goodsStatus_2_1") == '1') {
                        $("#goodsStatus_2 option[value= '1']").attr("selected", true);
                    }

                    if (sessionStorage.getItem("goodsName_2_1") == '') {
                        $("#goodsName_2").attr('placeholder','输入商品名')
                    }else{
                        $("#goodsName_2").attr('placeholder',sessionStorage.getItem("goodsName_2_1"))
                    }
                    
                    break;
                    case 'goodsAdd':
                    $("#goodsName").val('')
                    form.render('select'); //更新全部
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['500px', '400px'], //宽高
                        title: '商品信息添加',
                        btn: ['添加','取消'],
                        content: $('#goodsUpdate'),
                        yes: function(index){
                            var categoryId = $("#goodsCategory").val()
                            if ($("#goodsName").val() != '') {
                                var commodityName = $("#goodsName").val()
                            }
                            $.ajax({
                                type: "post",
                                url: "/admin/commodity/addComm",
                                data: {categoryId: categoryId,commodityName: commodityName},
                                dataType: "json",
                                success: function(mag){
                                    layer.msg('添加成功')
                                    table.reload('adTest')
                                }
                            })
                            layer.close(index);
                            getCategory(category)
                            form.render('select');
                        }
                    })
                    break;
                };
            });

            table.on('tool(test)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
                if(layEvent === 'goodsUpdate_1'){
                    $.ajax({
                        type: "get",
                        url: "/admin/commodity/getDetail/" + data.id,
                        data: '',
                        dataType: "json",
                        // async: false,
                        success: function(mag){
                            $(".goodscategory_info1").html(mag.data.category.categoryName)
                            $(".goodsname_info1").html(mag.data.commodityName)


                            var picture = mag.data.picture
                            if (picture.length != 0) {
                                var flag = ''
                                for (var i = 0; i < picture.length; i++) {
                                    var flag1 = '<label class="layui-col-sm2"><input type="checkbox" id="'+ picture[i].id +'"><img style="width: 90%;" src="https://vm.fowotek.com/'+ picture[i].picture_url +'"></label>'
                                    flag += flag1
                                }
                            }else{
                                flag = '<span style="height:150px;width: 150px;">未添加商品图片</span>'
                            }
                            $(".pic_info1").html(flag)
                            

                            var specifications = mag.data.specifications
                            if (specifications.length != 0) {
                                var flag = ''
                                for (var i = 0; i < specifications.length; i++) {
                                    var flag1 = '<tr><td>'+ specifications[i].id +'</td><td>'+ specifications[i].price +'</td><td>'+ specifications[i].specifications +'</td><td><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_mod" id="'+ specifications[i].id +'">修改</button><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_del" id="'+ specifications[i].id +'">删除</button></td></tr>' 
                                    flag += flag1
                                }
                            }else{
                                flag = '未添加规格'
                            }
                            $(".specifications_info1").html(flag)
                              
                        }
                    })
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['66%', '90%'], //宽高
                        title: '商品规格详细',
                        btn: ['刷新更改','关闭'],
                        content: $('#goodslistDetails'),
                        yes: function(index){
                            table.reload('adTest');
                            layer.close(index);
                            getCategory()
                        }
                    });

                    $(".goodslistDetails_modbtn").off('click').on('click',function(){
                        $("#goodsName").val('')
                        form.render('select'); //更新全部
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['500px', '400px'], //宽高
                            title: '商品信息修改',
                            btn: ['添加','取消'],
                            content: $('#goodsUpdate'),
                            yes: function(index){
                                var categoryId = $("#goodsCategory").val()
                                if ($("#goodsName").val() != '') {
                                    var commodityName = $("#goodsName").val()
                                }
                                $.ajax({
                                    type: "post",
                                    url: "/admin/commodity/updateComm",
                                    data: {commodityId:data.id,categoryId: categoryId,commodityName: commodityName},
                                    dataType: "json",
                                    success: function(mag){
                                        layer.msg(mag.message)
                                        $.ajax({
                                            type: "get",
                                            url: "/admin/commodity/getDetail/" + data.id,
                                            // data: {commodityId: data.id},
                                            dataType: 'json',
                                            async: false,
                                            success:function(mag){
                                                $(".goodscategory_info1").html(mag.data.category.categoryName)
                                                $(".goodsname_info1").html(mag.data.commodityName)
                                            }
                                        })
                                    }
                                })
                                layer.close(index);
                            }
                        })
                    })

                    $(".pic_updbtn").off('click').on('click',function(){
                        var file = $("#imgPath")[0].files[0];//获取文件
                        var formData = new FormData();
                        if (file == undefined) {
                            layer.msg('选择上传图片')
                        }else {
                            formData.append("picture", file);
                            formData.append("commodityId", data.id);
                            $.ajax({
                                type: "post",
                                url: "/admin/commodityPicture/addCommSpecification",
                                data: formData,
                                dataType: "json",
                                processData: false,
                                contentType: false,
                                success: function(res){
                                    layer.msg(res.message)
                                    $.ajax({
                                        type: "get",
                                        url: "/admin/commodityPicture/queryCommPicture/" + data.id,
                                        // data: {commodityId: data.id},
                                        dataType: 'json',
                                        async: false,
                                        success:function(mag){
                                            var picture = mag.data
                                            var flag = ''
                                            for (var i = 0; i < picture.length; i++) {
                                                var flag1 = '<label class="layui-col-sm2"><input type="checkbox" id="'+ picture[i].id +'"><img style="width: 90%;" src="https://vm.fowotek.com/'+ picture[i].picture_url +'"></label>'
                                                flag += flag1
                                            }
                                            $(".pic_info1").html(flag)
                                            $("#imgPath").val('')
                                        }
                                    })
                                }
                            })
                            layer.close(index);
                        }
                    })

                    $(".pic_delbtn").off('click').on('click',function(){
                        var inputchecked = $(this).closest("#goodslistDetails").find(".pic_info1").find('input')
                        for (let i = 0; i < inputchecked.length; i++) {
                            if (inputchecked[i].checked) {
                                $.ajax({
                                    type: "post",
                                    url: "/admin/commodityPicture/deleteCommSpecification",
                                    data: {commodityId: data.id,id: inputchecked[i].id},
                                    dataType: "json",
                                    async: false,
                                    success: function(mag){
                                        
                                    }
                                })
                            }
                            
                        }
                        $.ajax({
                            type: "get",
                            url: "/admin/commodityPicture/queryCommPicture/" + data.id,
                            // data: {commodityId: data.id},
                            dataType: 'json',
                            async: false,
                            success:function(mag){
                                var picture = mag.data
                                var flag = ''
                                for (var i = 0; i < picture.length; i++) {
                                    var flag1 = '<label class="layui-col-sm2"><input type="checkbox" id="'+ picture[i].id +'"><img style="width: 90%;" src="https://vm.fowotek.com/'+ picture[i].picture_url +'"></label>'
                                    flag += flag1
                                }
                                $(".pic_info1").html(flag)
                            }
                        })
                    })

                    $(document).off('click','.specifications_mod').on('click','.specifications_mod',function(){
                        $("#specificationPrice_2").val('')
                        $("#specification_2").val('')
                        var id = $(this).attr('id')
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['66%', '70%'], //宽高
                            title: '商品规格修改',
                            btn: ['修改','关闭'],
                            content: $('#specificationUpdate'),
                            yes:function(index){
                                var price = $("#specificationPrice_2").val()
                                var specification = $("#specification_2").val()
                                $.ajax({
                                    type: "post",
                                    url: "/admin/commoditySpecification/updateCommSpecification",
                                    data: {commodityId:data.id,id: id,price : price,specification: specification},
                                    dataType: "json",
                                    success: function(res){
                                        layer.msg(res.message)
                                        layer.close(index);
                                        $.ajax({
                                            type: "get",
                                            url: "/admin/commoditySpecification/queryCommSpecification/" + data.id,
                                            // data: {commodityId: data.id},
                                            dataType: 'json',
                                            success:function(mag){
                                                var specifications = mag.data
                                                if (specifications.length != 0) {
                                                    var flag = ''
                                                    for (var i = 0; i < specifications.length; i++) {
                                                        var flag1 = '<tr><td>'+ specifications[i].id +'</td><td>'+ specifications[i].price +'</td><td>'+ specifications[i].specifications +'</td><td><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_mod" id="'+ specifications[i].id +'">修改</button><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_del" id="'+ specifications[i].id +'">删除</button></td></tr>' 
                                                        flag += flag1
                                                    }
                                                }else{
                                                    flag = '未添加规格'
                                                }
                                                $(".specifications_info1").html(flag)
                                            }
                                        })
                                    }
                                })
                            }
                        });
                    })

                    $(document).off('click','.specifications_del').on('click','.specifications_del',function(){
                        
                        var id = $(this).attr('id')
                        layer.confirm('真的删除行么', function(index){
                            $.ajax({
                                type: "post",
                                url: "/admin/commoditySpecification/deleteCommSpecification",
                                data: {commodityId:data.id,id: id},
                                dataType: "json",
                                success: function(res){
                                    layer.msg(res.message)
                                    layer.close(index);
                                    $.ajax({
                                        type: "get",
                                        url: "/admin/commoditySpecification/queryCommSpecification/" + data.id,
                                        // data: {commodityId: data.id},
                                        dataType: 'json',
                                        success:function(mag){
                                            var specifications = mag.data
                                            if (specifications.length != 0) {
                                                var flag = ''
                                                for (var i = 0; i < specifications.length; i++) {
                                                    var flag1 = '<tr><td>'+ specifications[i].id +'</td><td>'+ specifications[i].price +'</td><td>'+ specifications[i].specifications +'</td><td><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_mod" id="'+ specifications[i].id +'">修改</button><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_del" id="'+ specifications[i].id +'">删除</button></td></tr>' 
                                                    flag += flag1
                                                }
                                            }else{
                                                flag = '未添加规格'
                                            }
                                            $(".specifications_info1").html(flag)
                                        }
                                    })
                                }
                            })
                        });
                    })

                    $(".specifications_add").off('click').on('click',function(){
                        $("#specificationPrice_2").val('')
                        $("#specification_2").val('')
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['66%', '70%'], //宽高
                            title: '商品规格修改',
                            btn: ['修改','关闭'],
                            content: $('#specificationUpdate'),
                            yes:function(index){
                                var price = $("#specificationPrice_2").val()
                                var specification = $("#specification_2").val()
                                $.ajax({
                                    type: "post",
                                    url: "/admin/commoditySpecification/addCommSpecification",
                                    data: {commodityId:data.id,price : price,specification: specification},
                                    dataType: "json",
                                    success: function(res){
                                        layer.msg(res.message)
                                        layer.close(index);
                                        $.ajax({
                                            type: "get",
                                            url: "/admin/commoditySpecification/queryCommSpecification/" + data.id,
                                            // data: {commodityId: data.id},
                                            dataType: 'json',
                                            success:function(mag){
                                                var specifications = mag.data
                                                var flag = ''
                                                for (var i = 0; i < specifications.length; i++) {
                                                    var flag1 = '<tr><td>'+ specifications[i].id +'</td><td>'+ specifications[i].price +'</td><td>'+ specifications[i].specifications +'</td><td><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_mod" id="'+ specifications[i].id +'">修改</button><button type="button" class="layui-btn layui-btn-xs layui-btn-radius specifications_del" id="'+ specifications[i].id +'">删除</button></td></tr>' 
                                                    flag += flag1
                                                }
                                                $(".specifications_info1").html(flag)
                                            }
                                        })
                                    }
                                })
                            }
                        });
                    })

                } else if(layEvent === 'goodsDel_1'){ //删除
                    layer.confirm('真的删除行么', function(index){
                        $.ajax({
                            type: "post",
                            url: "/admin/commodity/deleteComm",
                            data: {commodityId: data.id},
                            dataType: "json",
                            async: false,
                            success: function(mag){
                                layer.msg(mag.message)
                                // if (mag.success == true) {
                                //     obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    
                                // }
                            }
                        })
                        table.reload('adTest')
                        layer.close(index);
                        form.render('select');
                    });
                } else if(layEvent === 'goodsStatus_1'){ //编辑
                    if (data.commodityStatus == 0) {
                        layer.confirm('上架商品', function(index){
                            $.ajax({
                                type: "post",
                                url: "/admin/commodity/onTheMarket",
                                data: {commodityId: data.id},
                                dataType: "json",
                                success: function(mag){
                                    layer.msg(mag.message)
                                    if (mag.success == true) {
                                        obj.update({
                                            commodityStatus: '1'
                                        });
                                        layer.close(index);
                                    }
                                }
                            })
                            
                        });
                    }else {
                        layer.confirm('下架商品', function(index){
                            $.ajax({
                                type: "post",
                                url: "/admin/commodity/offTheShelf",
                                data: {commodityId: data.id},
                                dataType: "json",
                                success: function(mag){
                                    layer.msg(mag.message)
                                    if (mag.success == true) {
                                        obj.update({
                                            commodityStatus: '0'
                                        });
                                        layer.close(index);
                                    }
                                }
                            })
                            
                        });
                    }
                    
                }
            });
        
        



            function getCategory(num) {
                $.ajax({
                    type: "get",
                    url: "/admin/category",
                    data: '',
                    dataType: "json",
                    // async: false,
                    success: function(mag){
                        var tag = '<option value="">商品分类</option>'
                        for (let i = 0; i < mag.length; i++) {
                            if (mag[i].id == num) {
                                var tag1 = '<option selected="selected" value="'+ mag[i].id +'">'+ mag[i].categoryName +'</option>'
                            }else{
                                var tag1 = '<option value="'+ mag[i].id +'">'+ mag[i].categoryName +'</option>'
                            }
                            tag += tag1
                        }
                        $(".goodsCategory").html(tag)
                    }
                })
            }


        });
        function dateTime(date) {
            if (date != '') {
                var dateTime = new Date(date).getTime()
            }else{
                var dateTime = ''
            }
            return dateTime
        }
        function goodsStatus(num) {
            if (num == 0) {
                var status = '<span style="color: #f173e1;">未上架</span>'
            }else {
                var status = '正常'
            }
            return status
        }
        
    </script>
</body>
</html>